package org.apache.dubbo.demo.example.eg2;

import java.io.IOException;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;

public class Application {

  public static void main(String[] args) throws IOException {
    DemoService demoService = new DemoServiceImpl();

    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("demo-provider");

    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress("zookeeper://127.0.0.1:2181");

    ProtocolConfig protocolConfig = new ProtocolConfig();
    protocolConfig.setName("dubbo");
    protocolConfig.setPort(20880);
    protocolConfig.setThreads(200);

    ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
    serviceConfig.setApplication(applicationConfig);
    serviceConfig.setRegistry(registryConfig);
    serviceConfig.setProtocol(protocolConfig);
    serviceConfig.setInterface(DemoService.class);
    serviceConfig.setRef(demoService);
    serviceConfig.setVersion("1.0.0");

    serviceConfig.export();
    System.in.read();
  }

}
